#coding=utf-8
"""
Author:杭州多测师_周sir
Time:2025/8/28 15:56
website:https://duoceshi.net
"""

from config.config import *
import  time
import unittest
from public.utiles.HTMLTestRunnerNew import HTMLTestRunner
from public.utiles.mail import SendMail

# 定义生成测试报告的路径和测试报告的文件名称
now = time.strftime("%Y-%m-%d-%H-%M-%S")
filename = report_path +  "\\" + str(now) + "_ui_report.html"

def auto_run():
    discover = unittest.defaultTestLoader.discover(start_dir=testcase_path,
                                                   pattern="test_*.py")
    f = open(filename,'wb')
    runner = HTMLTestRunner(stream=f,
                            title="cms后台ui自动化测试报告",
                            description="测试用例执行如下",
                            tester="小周")
    runner.run(discover)
    f.close()

def sendMail():
    sm = SendMail(send_msg=filename,attachment=filename)
    sm.send_mail()
if __name__ == '__main__':
    auto_run()
    sendMail()

